﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using BCL.BaseLib.Basics;
using System.Drawing;
using BCL.BaseLib;
using System.IO;
namespace BCL.Main
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {

            Application app = new Application();

            app.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("/WPFComponent;component/Dictionary/GlobalDictionary.xaml", System.UriKind.Relative) });
            app.Resources.MergedDictionaries.Add(new ResourceDictionary { Source= new Uri("/WPFComponent;component/Dictionary/BorderStyle.xaml", System.UriKind.Relative) });
            app.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("/WPFComponent;component/Dictionary/DataGridDictionary.xaml", System.UriKind.Relative) });
            app.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("/WPFComponent;component/Dictionary/MuneDictionary.xaml", System.UriKind.Relative) });
            MemoryStream image = new MemoryStream(File.ReadAllBytes("image\\1.png"));

            MemoryStream image2 = new MemoryStream(File.ReadAllBytes("image\\2.png"));
            MemoryStream image3 = new MemoryStream(File.ReadAllBytes("image\\3.png"));
            MemoryStream image4 = new MemoryStream(File.ReadAllBytes("image\\4.png"));
            MemoryStream image5 = new MemoryStream(File.ReadAllBytes("image\\5.png"));
            MemoryStream image6 = new MemoryStream(File.ReadAllBytes("image\\6.png"));
            MemoryStream image7 = new MemoryStream(File.ReadAllBytes("image\\7.png"));
            List<FunctionEntity> fes = new List<FunctionEntity>();

            FunctionEntity fe = new FunctionEntity { AppCode = "001", AppId = "001", Title = "检查化验", ItemType = FunctionItemType.Group };
            fe.Items = new List<FunctionEntity>
            {
                //new FunctionEntity { AppCode = "00102", AppId = "00102", Title = "待检查", Index=true, ItemType = FunctionItemType.Item, FunctionType = FunctionType.Control, ClassInfo = new ClassInfo { DLLName = "XiaonuanPMS.dll", ClassFillName = "XiaonuanPMS.FormTestNew" }, Image = image2 },
                new FunctionEntity { AppCode = "00201", AppId = "00201", Title = "待检查",Index=true, ItemType = FunctionItemType.Item, FunctionType = FunctionType.Control, ClassInfo = new ClassInfo { DLLName = "WPFComponent.dll", ClassFillName = "BCL.WPFComponent.Datagrid" },ImagePath="image\\2.png" },
                new FunctionEntity { AppCode = "00101", AppId = "00101", Title = "已完成", ItemType = FunctionItemType.Item, FunctionType = FunctionType.Control, ClassInfo = new ClassInfo { DLLName = "WPFComponent.dll", ClassFillName = "BCL.WPFComponent.Datagrid" }, ImagePath="image\\1.png" },
            };
            fes.Add(fe);

            FunctionEntity fe2 = new FunctionEntity { AppCode = "002", AppId = "002", Title = "系统设置", ItemType = FunctionItemType.Group };
            fe2.Items = new List<FunctionEntity>
            {
                new FunctionEntity { AppCode = "00102", AppId = "00102", Title = "设备管理", ItemType = FunctionItemType.Item, FunctionType = FunctionType.Control, ClassInfo = new ClassInfo { DLLName = "WPFComponent.dll", ClassFillName = "BCL.WPFComponent.Datagrid" },ImagePath="image\\3.png" },
                new FunctionEntity { AppCode = "00103", AppId = "00103", Title = "医院信息", ItemType = FunctionItemType.Item, FunctionType = FunctionType.Control, ClassInfo = new ClassInfo { DLLName = "WPFComponent.dll", ClassFillName = "BCL.WPFComponent.Datagrid" },ImagePath="image\\4.png" },
                new FunctionEntity { AppCode = "00104", AppId = "00104", Title = "打印设置", ItemType = FunctionItemType.Item, FunctionType = FunctionType.Control, ClassInfo = new ClassInfo { DLLName = "WPFComponent.dll", ClassFillName = "BCL.WPFComponent.Datagrid" },ImagePath="image\\5.png" }

                //new FunctionEntity { AppCode = "00102", AppId = "00102", Title = "小暖", Index = true, ItemType = FunctionItemType.Item, FunctionType = FunctionType.Control, ClassInfo = new ClassInfo { DLLName = "XiaonuanPMS.dll", ClassFillName = "XiaonuanPMS.FormTestNew" }, Image = image2 },
                //new FunctionEntity { AppCode = "00201", AppId = "00201", Title = "检查", ItemType = FunctionItemType.Item, FunctionType = FunctionType.Control, ClassInfo = new ClassInfo { DLLName = "View.dll", ClassFillName = "DevicesView.FormTestNew" }, Image = image2 },
                //new FunctionEntity { ItemParamter = "http://www.huimopei.com:8888/management", AppCode = "00202", AppId = "00202", Title = "打印", ItemType = FunctionItemType.Item, FunctionType = FunctionType.Control, ClassInfo = new ClassInfo { DLLName = "View.dll", ClassFillName = "DevicesView.Web.WebControl" }, Image = image2 },
                //new FunctionEntity { ItemParamter = "http://localhost:8080/management", Index = true, AppCode = "00202", AppId = "00202", Title = "设备管理", ItemType = FunctionItemType.Item, FunctionType = FunctionType.Control, ClassInfo = new ClassInfo { DLLName = "View.dll", ClassFillName = "DevicesView.Web.WebControl" }, Image = image2 },
                //new FunctionEntity { ItemParamter = "http://www.huimopei.com:8888", Index = true, AppCode = "00203", AppId = "00203", Title = "网页2", ItemType = FunctionItemType.Item, FunctionType = FunctionType.Control, ClassInfo = new ClassInfo { DLLName = "View.dll", ClassFillName = "DevicesView.Web.WebControl" }, Image = image2 },
                //new FunctionEntity { ItemParamter = @"file:\\\D:\werkspaces\Lis\Lis.core\app\Debug\dist\index.html#/management", Index = true, AppCode = "002067", AppId = "0020345", Title = "网页34", ItemType = FunctionItemType.Item, FunctionType = FunctionType.Control, ClassInfo = new ClassInfo { DLLName = "View.dll", ClassFillName = "DevicesView.Web.WebControl" }, Image = image2 }
            };
            fes.Add(fe2);

            FunctionEntity fe3 = new FunctionEntity { AppCode = "003", AppId = "003", Title = "关于", ItemType = FunctionItemType.Group };
            fe3.Items = new List<FunctionEntity>
            {
                new FunctionEntity { AppCode = "00302", AppId = "00302", Title = "我的信息", ItemType = FunctionItemType.Item, FunctionType = FunctionType.Function, ClassInfo = new ClassInfo { DLLName = "WPFComponent.dll", ClassFillName = "BCL.WPFComponent.Datagrid" },ImagePath="image\\3.png" },
                new FunctionEntity { AppCode = "00303", AppId = "00303", Title = "技术支持", ItemType = FunctionItemType.Item, FunctionType = FunctionType.Function, ClassInfo = new ClassInfo { DLLName = "WPFComponent.dll", ClassFillName = "BCL.WPFComponent.Datagrid" },ImagePath="image\\3.png" },
            };
            //fes.Add(fe3);



            //随程序启动后台运行的应用
            FunctionEntity fe100 = new FunctionEntity { IsCreate = false, Title = "随程序启动，后台运行", ItemType = FunctionItemType.Group };
            fe100.Items = new List<FunctionEntity>
            {
               // new FunctionEntity { IsCreate=false, AppCode = "00102", AppId = "00102", StartLoad = true, ItemType = FunctionItemType.Item, FunctionType = FunctionType.Function, ClassInfo = new ClassInfo { DLLName = "Logic.dll", ClassFillName = "DevicesView.Logic.Test.CommandLogic" } }
            };

            fes.Add(fe100);
            app.Run(new WPFComponent.MainWindow(fes));



            //System.IO.FileSystemWatcher f = new System.IO.FileSystemWatcher();

            //System.Diagnostics.Process.GetProcessesByName("");
            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);

            //BonusSkins.Register();
            //SkinManager.EnableFormSkins();
            ////UserLookAndFeel.Default.SetSkinStyle("Office 2010 Blue");//"Office 2013"

            //Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            ////处理UI线程异常
            //Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            //////处理非UI线程异常
            //AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            ////System.Drawing.Image image = System.Drawing.Bitmap.FromFile("image\\1.png");
            ////System.Drawing.Image image2 = System.Drawing.Bitmap.FromFile("image\\2.png");
            ////System.Drawing.Image image3 = System.Drawing.Bitmap.FromFile("image\\3.png");


            ////List<FunctionEntity> fes = new List<FunctionEntity>();
            ////FunctionEntity fe = new FunctionEntity { AppCode = "001", AppId = "001", Title = "检查化验", ItemType = FunctionItemType.Group };
            ////fe.Items = new List<FunctionEntity>
            ////{
            ////    new FunctionEntity { AppCode = "00102", AppId = "00102", Title = "待检查", Index=true, ItemType = FunctionItemType.Item, FunctionType = FunctionType.Control, ClassInfo = new ClassInfo { DLLName = "XiaonuanPMS.dll", ClassFillName = "XiaonuanPMS.FormTestNew" }, Image = image2 },
            ////    //new FunctionEntity { AppCode = "00201", AppId = "00201", Title = "检查", ItemType = FunctionItemType.Item, FunctionType = FunctionType.Control, ClassInfo = new ClassInfo { DLLName = "View.dll", ClassFillName = "DevicesView.FormTestNew" }, Image = image2 },
            ////    new FunctionEntity { AppCode = "00101", AppId = "00101", Title = "已完成", ItemType = FunctionItemType.Item, FunctionType = FunctionType.Control, ClassInfo = new ClassInfo { DLLName = "View.dll", ClassFillName = "DevicesView.UserControlRelust" }, Image = image },
            ////};
            ////fes.Add(fe);

            //Form1 form1 = new Form1();
            //form1.Functiones = null;
            //Application.Run(form1);
            ////Application.Run(new Form1());
        }

        static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            //MessageBox.Show(e.Exception.Message);
            //ClientCommon.Logs.Log(e.Exception.Message, e.Exception.StackTrace);
            //BCLApplication.log.Write(e.Exception.Message);
        }

        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            //ClientCommon.Logs.Log(e.ExceptionObject.ToString());
            //BCLApplication.log.Write(e.ExceptionObject.ToString());
        }
    }
}
